#!/usr/bin/env bash

export $(grep -v '^#' /etc/environment | xargs)
export DEBIAN_FRONTEND=noninteractive

apt-get update
apt-get install python3-pip docker.io libsquashfuse0 squashfuse fuse snapd -y
pip3 install pytest==8.3.4 requests pyyaml sh psutil
# Attempting to address https://forum.snapcraft.io/t/lxd-refresh-cause-container-socket-error/8698
# if core is to be installed by microk8s it fails

# wait for the snapd seeding to take place!
n=0
until [ $n -ge 7 ]
do
  sudo snap install core && break  # substitute your command here
  n=$[$n+1]
  sleep 10
done

n=0
until [ $n -ge 7 ]
do
  sudo snap install core22 && break  # substitute your command here
  n=$[$n+1]
  sleep 10
done
